package com.magnusart.scrumppm.presenters;

import com.magnusart.scrumppm.model.LocalObservable;
import com.magnusart.scrumppm.model.Project;


/**
 * Contains some global settings. Like the current active project
 * @author Magnus Andersson
 *
 */
public class GlobalEvents
{
	/**
	 * Current active project used in the application
	 */
	private static Project activeProject;
	
	/**
	 * An delegator reference.
	 */
	private static final LocalObservable obs = new LocalObservable();
	
	/**
	 * Lists global events that can occur
	 */
	public static enum Events {
		UPDATE_CURRENT_PROJECT,
		REFRESH_PROJECT_LISTINGS
	}
	
	private GlobalEvents() { /*Nothing*/ }
	
	public static Project getActiveProject() {
		return activeProject;
	}

	public static void setCurrentProject( Project currentProject ) {
		GlobalEvents.activeProject = currentProject;
		obs.announce( Events.UPDATE_CURRENT_PROJECT );
	}

	public static LocalObservable observe() {
		return obs;
	}

	public static void refreshProjectListings() {
		obs.announce( Events.REFRESH_PROJECT_LISTINGS );
	}
}
